package com.qianfeng.smartdevice.mapper;

import com.qianfeng.smartdevice.pojo.Humiture;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

// 注意一个异常, 关于单个参数名字随便写,但是 sql 中写了好多个参数的问题
public interface HumitureMapper {
    @Insert("INSERT INTO humiture (deviceUUID,humidity,temperature,uploaddate) VALUES(#{deviceUuid},#{humidity},#{temperature},#{uploaddate})")
    void addHumiture(Humiture humiture);
    //此处应该可以传递设备 id  ,但是我们忽略了,快速显示下数据
    @Select("SELECT * FROM humiture WHERE uploaddate BETWEEN #{before} And #{current}")
    List<Humiture> findHumituresByDate(@Param("before") Date brfore, @Param("current") Date current);
}
